home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / imb9004.zip / MOUSE.BAS < prev    next >
BASIC Source File  |  1990-04-01  |  2KB  |  106 lines

  1. 'Program:   Master Mouse Routine Library
  2. '           MOUSE.BAS
  3.  
  4. '$INCLUDE: 'QB.BI'
  5. '$INCLUDE: 'MOUSE.BI'
  6.  
  7. DEFINT A-Z
  8.  
  9. DIM SHARED MouseVisible, MHMax, MVMax
  10. DIM SHARED MouseIntr, MHCell, MVCell
  11.  
  12. SUB ClearButton (Button)
  13.     WHILE NOT GetButtonUpStatus(Button, 0, 0): WEND
  14. END SUB
  15.  
  16. FUNCTION GetButtonUpStatus (Button, MPosX, MPosY)
  17.     ax = 6
  18.     bx = Button
  19.     OutRegs.AX = 0
  20.     OutRegs.BX = 0
  21.     OutRegs.CX = 0
  22.     OutRegs.DX = 0
  23.     MouseHandler AX, BX, 0, 0
  24.     MPosX = OutRegs.CX \ MHCell + 1
  25.     MPosY = OutRegs.DX \ MVCell + 1
  26.     IF OutRegs.AX = 0 THEN
  27.         GetButtonUpStatus = True
  28.     ELSE
  29.         GetButtonUpStatus = False
  30.     END IF
  31. END FUNCTION
  32.  
  33. FUNCTION GetMouseStatus (MPosX, MPosY)
  34.     AX = 3
  35.     OutRegs.BX = 0: OutRegs.CX = 0: OutRegs.DX = 0
  36.     MouseHandler AX, 0, 0, 0
  37.     GetMouseStatus = OutRegs.BX
  38.     MPosX = OutRegs.CX \ MHCell + 1
  39.     MPosY = OutRegs.DX \ MVCell + 1
  40. END FUNCTION
  41.  
  42. SUB MouseHandler (AX, BX, CX, DX)
  43. DIM InRegs AS RegType
  44.     InRegs.AX = AX
  45.     InRegs.BX = BX
  46.     InRegs.CX = CX
  47.     InRegs.DX = DX
  48.     INTERRUPT MouseIntr, InRegs, OutRegs
  49. END SUB
  50.  
  51. SUB MouseOff
  52.     IF MouseVisible THEN
  53.         MouseHandler 2, 0, 0, 0
  54.         MouseVisible = False
  55.     END IF
  56. END SUB
  57.  
  58. SUB MouseOn
  59.     IF NOT MouseVisible THEN
  60.         MouseHandler 1, 0, 0, 0
  61.         MouseVisible = True
  62.     END IF
  63. END SUB
  64.  
  65. FUNCTION MouseReset
  66.   MHMax = 639 'Max virtual horizontal mouse pos
  67.   MVMax = 199 'Max virtual vertical mouse pos
  68.   MHCell = 8  'Mouse horizontal cell width
  69.   MVCell = 8  'Mouse vertical cell height
  70.   MouseIntr = &H33
  71.   MouseHandler 0, 0, 0, 0
  72.   MouseReset = OutRegs.AX
  73.   MouseVisible = False
  74. END FUNCTION
  75.  
  76. SUB SetMouseSoftCursor_
  77.    (MouseChar, MouseFGColor, MouseBGColor)
  78.     MouseOn
  79.     AX = 10
  80.     BX = 0       'Select software cursor
  81.     CX = &H8800  'Screen Mask Value 
  82.     DX = &H8800 + MouseBGColor * 4096 +_
  83.          MouseFGColor * 256 + MouseChar
  84.     MouseHandler AX, BX, CX, DX
  85.     MouseOff
  86. END SUB
  87.  
  88. FUNCTION ThereIsAMouse
  89.     IRET = 207
  90.     DEF SEG = 0    'Set to base system address
  91.     MouseSegment = PEEK(207) * 256 + PEEK(206)
  92.     MouseOffset = PEEK(205) * 256 + PEEK(204)
  93.     IF MouseSegment = 0 AND MouseOffset = 0 THEN
  94.         ThereIsAMouse = False
  95.     ELSE
  96.         DEF SEG = MouseSegment
  97.         MouseInstruction = PEEK(MouseOffset)
  98.         IF MouseInstruction = IRET THEN
  99.             ThereIsAMouse = False
  100.         ELSE
  101.             ThereIsAMouse = True
  102.         END IF
  103.     END IF
  104.     DEF SEG
  105. END FUNCTION
  106.